package com.xiaoshuidi.cloud.module.iot.enums;

import org.springframework.util.StringUtils;

/**
 * 琨山门锁回调开门记录时，指定开门方式
 */
public enum KunShanOpenDoorWayEnum {

    // 1.密码 2.指纹 3.卡片 4.蓝牙 5.远程 6.一次性密码 15.身份证
    ON_LINE("1", "密码",CommonOpenDoorType.PASS_OPEN.getDesc()),
    FINGER_PRINT("2", "指纹",CommonOpenDoorType.FINGER_PRINT_OPEN.getDesc()),
    CARD("3", "卡片",CommonOpenDoorType.CARD_OPEN.getDesc()),
    BLUE_TOOTH("4", "蓝牙",CommonOpenDoorType.APP_BLT_OPEN.getDesc()),
    DISTANCE_CONTROL("5", "远程",CommonOpenDoorType.NO_APPLY.getDesc()),
    DYNAMIC("6", "一次性密码",CommonOpenDoorType.DYNAMIC_OPEN.getDesc()),
    ID_CARD("15", "身份证",CommonOpenDoorType.NO_APPLY.getDesc());
    String unlockWay;
    String desc;
    String mapping;

    KunShanOpenDoorWayEnum(String unlockWay, String desc, String mapping) {
        this.unlockWay = unlockWay;
        this.desc = desc;
        this.mapping = mapping;
    }

    public String getUnlockWay() {
        return unlockWay;
    }

    public String getDesc() {
        return desc;
    }

    public String getMapping() {
        return mapping;
    }

    public static KunShanOpenDoorWayEnum getInstance(String code) {
        if (StringUtils.isEmpty(code)) {
            return null;
        }
        for (KunShanOpenDoorWayEnum instance : values()) {
            if (instance.getUnlockWay().equals(code)) {
                return instance;
            }
        }
        return null;
    }
}

